#include "demo3d.h"

Demo3d::Demo3d() : BaseApp()
{

}

void Demo3d::Initialize()
{
    BaseApp::Initialize();

#if 1
    camera = std::make_shared<kanon::Camera3d>(glm::vec3(0.0f, 0.0f, 0.0f));
    camera->setWindowSize(window->GetWidth(), window->GetHeight());

    mesh_renderer = std::make_shared<kanon::MeshRenderer>();
    std::string gltf_root = "D:/projects_learn/glTF-Sample-Models-main/2.0";
    std::string gltf_path = gltf_root + "/Avocado/glTF-Binary/Avocado.glb";
    model = std::make_shared<kanon::Model>();
    model->fromGltf(gltf_path);
#endif
}

void Demo3d::Render()
{

#if 1
    this->mesh_renderer->Begin();
    this->mesh_renderer->SetCamera(camera);
    this->mesh_renderer->Render(model);
    this->mesh_renderer->End();
#endif
    this->RenderUI();
}

void Demo3d::RegisterEvents()
{

}

void Demo3d::RenderUI()
{
    ui_layer->BeginFrame();
    ui_layer->ShowSample();
    ui_layer->EndFrame();
}
